<?php


namespace app\controller;


use app\model\categoryModel;
use think\facade\Request;

class category
{
private $model;

    public function __construct()
    {
        $this->model = new categoryModel();
}

    public function add()
    {
        $data = Request::post();
        $this->model->addData($data);
        return json(['meta'=>['msg'=>'新增成功','status'=>200]]);
}

    public function getList($id)
    {
        $data = $this->model->where(['type_id'=>$id])->select()->toArray();
        file_put_contents('1.txt', var_export($data, 1));
        if ($data) $meta=['status'=>200];
        else $meta=['status'=>400];
        return json(['data'=>$data,'meta'=>$meta]);
}
}